package cn.iocoder.yudao.module.custom.service.industry;

import cn.iocoder.yudao.module.custom.dal.dataobject.industry.IndustryDO;
import cn.iocoder.yudao.module.custom.dal.mysql.industry.IndustryMapper;

import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;

import org.springframework.stereotype.Service;

import static cn.iocoder.yudao.module.custom.enums.ErrorCodeConstants.*;

import javax.annotation.Resource;

import org.springframework.validation.annotation.Validated;

import java.util.*;


/**
 * 行业分类信息 Service 实现类
 *
 * @author 芋道源码
 */
@Service
@Validated
public class IndustryServiceImpl implements IndustryService {

    @Resource
    private IndustryMapper industryMapper;


    @Override
    public List<IndustryDO> getSecondaryIndustryList(Integer industryCode) {
        // 判断行业code是否为空和是否为纯数字
        if (industryCode == null) {
            throw exception(INDUSTRY_ID_NOT_NULL);
        }
        if (!industryCode.toString().matches("[0-9]*")) {
            throw exception(INDUSTRY_FORMAT_ERROR);
        }
        return industryMapper.getSecondaryIndustryList(industryCode);
    }

}
